package top.wshape1.rpc.filter;

import lombok.Getter;

/**
 * @author Wshape1
 * @version 1.0
 * @description
 * @since 2024-02-15
 */

public class FilterChainFactory {

    /**
     * 消费者在发送RpcRequest时的过滤器链
     */
    private final static FilterChain consumerSendReqFilterChain;

    /**
     * 消费者在接收RpcResponse时的过滤器链
     */
    private final static FilterChain consumerRecRespFilterChain;

    /**
     * 生产者在接收RpcRequest时的过滤器链
     */
    private final static FilterChain providerRecReqFilterChain;

    /**
     * 生产者在发送RpcResponse时的过滤器链
     */
    private final static FilterChain providerSendRespFilterChain;


    static {
        Filter consumerTokenFilter = new ConsumerTokenFilter();
        Filter providerTokenFilter = new ProviderTokenFilter();

        consumerSendReqFilterChain = new FilterChain();
        consumerSendReqFilterChain.addFilter(consumerTokenFilter);

        consumerRecRespFilterChain = new FilterChain();
        consumerRecRespFilterChain.addFilter(consumerTokenFilter);

        providerRecReqFilterChain = new FilterChain();
        providerRecReqFilterChain.addFilter(providerTokenFilter);

        providerSendRespFilterChain = new FilterChain();
        providerSendRespFilterChain.addFilter(providerTokenFilter);
    }

    /**
     * 获取消费者在发送RpcRequest时的过滤器链
     *
     * @return FilterChain
     */
    public static FilterChain getConsumerSendReqFilterChain() {
        return consumerSendReqFilterChain;
    }

    /**
     * 获取消费者在接收RpcResponse时的过滤器链
     *
     * @return FilterChain
     */
    public static FilterChain getConsumerRecRespFilterChain() {
        return consumerRecRespFilterChain;
    }

    /**
     * 获取生产者在接收RpcRequest时的过滤器链
     *
     * @return FilterChain
     */
    public static FilterChain getProviderRecReqFilterChain() {
        return providerRecReqFilterChain;
    }

    /**
     * 获取生产者在发送RpcResponse时的过滤器链
     *
     * @return FilterChain
     */
    public static FilterChain getProviderSendRespFilterChain() {
        return providerSendRespFilterChain;
    }


}
